package servletlearn.readresource.dao;

import java.io.*;
import java.util.Properties;

/**
 * Created by Administrator on 2017/5/30.
 */
public class UserDao {
    //在普通类中读取文件需要用classloader读取
    public String test() throws IOException {
//        InputStream pro = getClass().getClassLoader().getResourceAsStream("");
        String path = getClass().getClassLoader().getResource("db.properties").getPath();
        System.out.println(path);
        Properties pro = new Properties();
        pro.load(new FileInputStream(path));
        return pro.getProperty("username");

    }
}
